package com.youtills.resource;

import com.youtills.action.ActionContext;
import com.youtills.resource.date.SystemDateManager;

import java.util.Date;

/**
 * TODO - !!!doc me!!!
 *
 * @author ravi.chiluveru
 * @since 23.0 (10/4/14)
 */
public interface DateManager {

    DateManager instance = new Singleton();

    Date getCurrentDate(final ActionContext ac);
    long getCurrentTimeMillis(final ActionContext ac);

    class Singleton implements DateManager {

        private final DateManager defaultManager;

        private Singleton() {
            defaultManager = SystemDateManager.instance;
        }

        @Override
        public Date getCurrentDate(final ActionContext ac) {
            return getManager(ac).getCurrentDate(ac);
        }

        @Override
        public long getCurrentTimeMillis(final ActionContext ac) {
            return getManager(ac).getCurrentTimeMillis(ac);
        }

        private DateManager getManager(ActionContext ac) {
            //TODO implement context based managers.
            return defaultManager;
        }
    }

}
